/**
 * @description 数据键值对-控制器
 * @since 2019-11-12
 * @author Rid King
*/

const ox = require('@daelui/oxjs')
const BaseController = require('../base/index.js')
const Service = require('./service.js')

class Controller extends BaseController {
  /**
   * @function 构造方法
  */
  constructor (args) {
    super(args)
    // 服务
    this.$service = new Service(args)
  }

  // 首页
  index (action) {
    return this.$router.getControllInstance({path: '/dblog/note'}).queryNotes(action).then(res => {
      let data = res.data || {}
      return this.renderTpl('/index/index.ejs', {
        data: {
          news: data.list,
          notes: data.list
        }
      }).then(tpl => {
        return {
          data: tpl
        }
      })
    })
  }
}

module.exports = Controller